package com.tougutips.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.tougutips.common.goods.vo.SeckGoodsVO;
import com.tougutips.entity.Goods;
import com.tougutips.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @GetMapping("/list")
    public AjaxResult list(){
        List<Goods> list = goodsService.list();
        return AjaxResult.success(list);
    }

    @PostMapping
    public AjaxResult save(@RequestBody Goods goods){
        boolean save = goodsService.save(goods);
        if(save) return AjaxResult.success("新增商品成功");
        return AjaxResult.error("新增商品失败");
    }
}
